package com.gec.zhs.controller;

import java.util.List;

import com.gec.zhs.entity.query.FlowinstanceQuery;
import com.gec.zhs.entity.po.Flowinstance;
import com.gec.zhs.entity.vo.ResponseVO;
import com.gec.zhs.service.FlowinstanceService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 工作流流程实例表 Controller
 */
@RestController("flowinstanceController")
@RequestMapping("/flowinstance")
public class FlowinstanceController extends ABaseController{

	@Resource
	private FlowinstanceService flowinstanceService;
	/**
	 * 根据条件分页查询
	 */
	@RequestMapping("/loadDataList")
	public ResponseVO loadDataList(FlowinstanceQuery query){
		return getSuccessResponseVO(flowinstanceService.findListByPage(query));
	}

	/**
	 * 新增
	 */
	@RequestMapping("/add")
	public ResponseVO add(Flowinstance bean) {
		flowinstanceService.add(bean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增
	 */
	@RequestMapping("/addBatch")
	public ResponseVO addBatch(@RequestBody List<Flowinstance> listBean) {
		flowinstanceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 批量新增/修改
	 */
	@RequestMapping("/addOrUpdateBatch")
	public ResponseVO addOrUpdateBatch(@RequestBody List<Flowinstance> listBean) {
		flowinstanceService.addBatch(listBean);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id查询对象
	 */
	@RequestMapping("/getFlowinstanceById")
	public ResponseVO getFlowinstanceById(String id) {
		return getSuccessResponseVO(flowinstanceService.getFlowinstanceById(id));
	}

	/**
	 * 根据Id修改对象
	 */
	@RequestMapping("/updateFlowinstanceById")
	public ResponseVO updateFlowinstanceById(Flowinstance bean,String id) {
		flowinstanceService.updateFlowinstanceById(bean,id);
		return getSuccessResponseVO(null);
	}

	/**
	 * 根据Id删除
	 */
	@RequestMapping("/deleteFlowinstanceById")
	public ResponseVO deleteFlowinstanceById(String id) {
		flowinstanceService.deleteFlowinstanceById(id);
		return getSuccessResponseVO(null);
	}
}